<template>
	<div>
  <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      fixed
      prop="mno"
      label="采购清单号"
      width="150">
    </el-table-column>
    <el-table-column
      prop="eno"
      label="员工编号"
      width="150">
    </el-table-column>
    <el-table-column
      prop="mcount"
      label="采购数量"
      width="100">
    </el-table-column>
    <el-table-column
      prop="mmoney"
      label="采购总价"
      width="120">
    </el-table-column>
    <el-table-column
      prop="mtime"
      label="采购时间"
      width="150">
    </el-table-column>
	<el-table-column
	  prop="mremark"
	  label="备注"
	  width="150">
	</el-table-column>
    <el-table-column
          fixed="right"
          label="操作"
          width="400">
          <template slot-scope="scope">
            <el-button @click="edit(scope.row)" type="text" size="small">修改</el-button>
            <el-button  @click="deletemain(scope.row)" type="text" size="small">删除</el-button>
          </template>
    </el-table-column>
  </el-table>
  <el-pagination
    background
    layout="prev, pager, next"
	page-size="5"
    :total="total"
	@current-change="page">
  </el-pagination>
  </div>
</template>

<script>
  export default {
	  name: "MainSearch",
    methods: {
		deletemain(row){
			const _this = this
			axios.delete('http://localhost:8181/main/deleteById/'+row.mno).then(function(resp){
					_this.$message('删除成功！');
					window.location.reload();				
			})
		},
		edit(row) {
		  this.$router.push({
					path:'/mainupdate',
					query:{
						id:row.mno
					}
				})
		},
	  page(currentPage){
		  const _this = this
		  axios.get('http://localhost:8181/main/findAll/'+currentPage+'/5').then(function(resp){
		  	_this.tableData = resp.data.content
		  	_this.total = resp.data.totalElements
		  })
	  }
    },
	created(){
		const _this = this
		axios.get('http://localhost:8181/main/findAll/1/6').then(function(resp){
			console.log(resp)
			_this.tableData = resp.data.content
			_this.total = resp.data.totalElements
		})
		
	},
    data() {
      return {
		  total: null,
			tableData: null
      }
    }
  }
</script>
